#include "AudioManage.h"


AudioManage::AudioManage()
{
}


AudioManage::~AudioManage()
{
}

int AudioManage::startID = -1;
int AudioManage::playID = -1;
int AudioManage::playID2 = -1;
float AudioManage::s_flVPercent = 1.0f;


void AudioManage::playStartMusic()
{
	startID = AudioEngine::play2d("Music/start.mp3", true, 0.5f);
}

void AudioManage::playPlayMusic()
{
	playID = AudioEngine::play2d("Music/play.mp3", true, 0.5f);
}

void AudioManage::changePlayMusic()
{
	float flVPercent = AudioEngine::getVolume(playID);
	AudioEngine::stop(playID);

	playID2 = AudioEngine::play2d("Music/play2.mp3", true, 0.5f);
	AudioEngine::setVolume(playID2, flVPercent * 0.5);
}

void AudioManage::pausePlayMusic()
{
	AudioEngine::pause(playID);
}

void AudioManage::continuePlayMusic()
{
	AudioEngine::resume(playID);
}

void AudioManage::stopStartMusic()
{
	if (startID > -1)
	{
		AudioEngine::stop(startID);
	}
}

void AudioManage::stopPlayMusic()
{
	if (playID > -1)
	{
		AudioEngine::stop(playID);
	}

	if (playID2 > -1)
	{
		AudioEngine::stop(playID2);
	}
}

void AudioManage::buttonSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/button.mp3", false, s_flVPercent);
    return;
#endif
    
	AudioEngine::play2d("Music/button.ogg", false, s_flVPercent);
}

void AudioManage::button1Sound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/button1.mp3", false, s_flVPercent);
    return;
#endif
    
	AudioEngine::play2d("Music/button1.ogg", false, s_flVPercent);
}

void AudioManage::button2Sound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/button2.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/button2.ogg", false, s_flVPercent);
}

void AudioManage::cardSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/card.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/card.ogg", false, s_flVPercent);
}

void AudioManage::bellSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/bell.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/bell.ogg", false, s_flVPercent);
}

void AudioManage::comboSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/combo.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/combo.ogg", false, s_flVPercent);
}

void AudioManage::cupSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/cup.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/cup.ogg", false, s_flVPercent);
}

void AudioManage::rightSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/right.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/right.ogg", false, s_flVPercent);
}

void AudioManage::wrongSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/wrong.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/wrong.ogg", false, s_flVPercent);
}

void AudioManage::playEndMusic()
{
	AudioEngine::play2d("Music/end.mp3", false, s_flVPercent);
}

void AudioManage::walkSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/walk.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/walk.ogg", false, s_flVPercent);
}

void AudioManage::diceSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/dice.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/dice.ogg", false, s_flVPercent);
}

void AudioManage::bangSound()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    AudioEngine::play2d("Music/bang.mp3", false, s_flVPercent);
    return;
#endif
	AudioEngine::play2d("Music/bang.ogg", false, s_flVPercent);
}

void AudioManage::setEffectSound(float flPercent)
{
	s_flVPercent = flPercent;
}

void AudioManage::setMusicSound(float flPercent)
{
	AudioEngine::setVolume(startID, flPercent * 0.5);
	AudioEngine::setVolume(playID, flPercent * 0.5);
	AudioEngine::setVolume(playID2, flPercent * 0.5);
}
